﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Jxym.wlkc2011.Module.CMS.MODEL;
using Jxym.DBUtility;

namespace Jxym.wlkc2011.WebSite
{
    public partial class _default : System.Web.UI.Page
    {
        public int index = 1;
        private string _ps = "";
        private IList<Cms_Site> _list = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BinData();
            }
        }
        private void BinData()
        {
            try
            {
                MsSqlDal<Cms_Site> cs = new MsSqlDal<Cms_Site>();

                string where = "";

                if (Request.Params["ps"] != null)
                {
                    _ps = Server.UrlDecode(Request.Params["ps"]);
                    where = "TITLE LIKE '%" + _ps + "%'";
                }
                AspNetPager1.RecordCount = cs.GetPageCount(where, null);
                _list = cs.GetPageList(where, null, AspNetPager1.StartRecordIndex, AspNetPager1.PageSize);
                if (AspNetPager1.RecordCount > 0)
                {
                    rp_List.DataSource = _list;
                    rp_List.DataBind();
                }
                else
                {
                    Label1.Text = "<div style='padding:0px 20px; background-color: #efefef;color: #000;'>系统提示：<br/>抱歉！没有找到与“<span style='color: #f00;'>" + _ps + "</span>”关键字相关的课程</div>";
                }
            }
            catch (Exception ex)
            {
                Label1.Text = "<div style='padding:0px 20px; background-color: #efefef;color: #000;'>系统提示：<br/>抱歉！“<span style='color: #f00;'>" + ex.Message + "</span>”</div>";
            }
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            BinData();
        }
    }
}